﻿$scriptPath = $PSCommandPath
$scriptfile = Get-Item -Path $scriptPath

$currentFolder = $scriptfile.Directory.FullName
$currentFolder = "D:\devel\"


$CertificateFilePath = Join-Path -Path $currentFolder -ChildPath "testCertificates.cer"
$CertificateThumbprint = "CC:04:C4:FC:DD:6A:5E:53:EA:21:20:74:B9:70:85:C1:07:3B:F8:64"
$CertificateAlias = "YGO"
$JavaFolderPath = "C:\Program Files\Java\jre7"



Get-TargetResource -CertificateFilePath $CertificateFilePath -CertificateThumbprint $CertificateThumbprint `
                   -CertificateAlias $CertificateAlias -JavaFolderPath $JavaFolderPath


Test-TargetResource -CertificateFilePath $CertificateFilePath -CertificateThumbprint $CertificateThumbprint `
                    -CertificateAlias $CertificateAlias -JavaFolderPath $JavaFolderPath -Ensure "Present"

Test-TargetResource -CertificateFilePath $CertificateFilePath -CertificateThumbprint $CertificateThumbprint `
                    -CertificateAlias $CertificateAlias -JavaFolderPath $JavaFolderPath -Ensure "Absent"


Set-TargetResource -CertificateFilePath $CertificateFilePath -CertificateThumbprint $CertificateThumbprint `
                   -CertificateAlias $CertificateAlias -JavaFolderPath $JavaFolderPath -Ensure Absent

Set-TargetResource -CertificateFilePath $CertificateFilePath -CertificateThumbprint $CertificateThumbprint `
                   -CertificateAlias $CertificateAlias -JavaFolderPath $JavaFolderPath -Ensure Present


Add-JavaCertificate -JavaFolderPath $JavaFolderPath -CertificateFilePath $CertificateFilePath -CertificateAlias $CertificateAlias
Remove-JavaCertificate -JavaFolderPath $JavaFolderPath -CertificateAlias $CertificateAlias

Test-ExistJavaCertificate -JavaFolderPath $JavaFolderPath -CertificateFilePath $CertificateFilePath


Get-JavaCertificateThumbprint -JavaFolderPath $JavaFolderPath -CertificateFilePath $CertificateFilePath
Get-InstalledJavaCertificates -JavaFolderPath $JavaFolderPath
$testkeytoolPath = Get-JavaKeytoolExePath -JavaFolderPath $JavaFolderPath
Invoke-JavaKeytool -KeytoolExePath $testkeytoolPath -KeytoolCommand "-help"
Invoke-JavaKeytool -KeytoolExePath $testkeytoolPath -KeytoolCommand '-list -keystore "C:\Program Files\Java\jre7\lib\security\cacerts" -storepass changeit'
#Invoke-JavaKeytool -KeytoolExePath $testkeytoolPath -KeytoolCommand '-importcert -noprompt -keystore "C:\Program Files\Java\jre7\lib\security\cacerts" -storepass changeit -file "CertificateFilePath" -alias YGO8'
